package com.twxm.breed.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;

import java.util.Date;

@Data
@Table(name = "weatherfactor")
public class WeatherFactor implements FactorImpl {
    @IsKey
    @TableId
    @IsAutoIncrement
    private int weatherId;

    @Column(comment = "气温",type = MySqlTypeConstant.FLOAT,decimalLength = 2)
    @IsNotNull
    private float temperature;

    @Column(comment = "风速",type = MySqlTypeConstant.FLOAT,decimalLength = 2)
    @IsNotNull
    private float windSpeed;

    @Column(comment = "气压",type = MySqlTypeConstant.FLOAT,decimalLength = 2)
    @IsNotNull
    private float airPressure;

    @Column(comment = "光照",type = MySqlTypeConstant.FLOAT,decimalLength = 2)
    @IsNotNull
    private float illumination;

    @Column(comment = "湿度",type = MySqlTypeConstant.FLOAT,decimalLength = 2)
    @IsNotNull
    private float humidity;

    @Column(comment = "采集时间",type = MySqlTypeConstant.DATETIME)
    @IsNotNull
    private Date collectionTime;

    @Column(name = "pond_id",type = MySqlTypeConstant.VARCHAR)
    @IsNotNull
    private FishPond fishPond;

    public WeatherFactor(float temperature, float windSpeed, float airPressure, float illumination, float humidity, Date date, FishPond fishPond) {
        this.temperature = temperature;
        this.windSpeed = windSpeed;
        this.airPressure = airPressure;
        this.illumination = illumination;
        this.humidity = humidity;
        this.collectionTime = date;
        this.fishPond = fishPond;
    }

    @Override
    public float getContent(String el) {
        switch (el){
            case "temperature":
                return temperature;
            case "windSpeed":
                return windSpeed;
            case "airPressure":
                return airPressure;
            case "illumination":
                return illumination;
            case "humidity":
                return humidity;
            default:
                return 0;
        }
    }
}
